// SensorWrapperApp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <csignal>
#include "../SensorWrapper/SensorWrapper.h"


int try_print_data() {
	int x, y, z;
	if (sensor_try_access_data(x, y, z) == 0) {
		printf("x: %d y: %d z: %u\n", x, y, z);
	}
	return 0;
}


int main()
{
	while (getchar() == 'c') {
		sensor_init();
		int value = 1;
		sensor_set_context(SENSOR_VAR_DISPLAY, 1, &value);
		int len = sensor_get_context(SENSOR_VAR_DISPLAY, 1, &value);
		if (len && value) std::cout << "Set display to TRUE" << std::endl;
		else std::cout << "Failed to set variable display" << std::endl;
		int counter = 200000;
		while (counter > 0) {
			sensor_update();
			try_print_data();
			counter--;
			if (counter % 20 == 0) std::cout << counter << std::endl;
		}
		sensor_destroy();
		getchar();
	}
}